﻿#include <Solar/CelestialBody.h>
CCelestialBody::CCelestialBody(SCelestialBodyEle stCelestialBodyEle)
	:m_stCelestialBodyEle(stCelestialBodyEle)
	,m_rpMT(nullptr)
	,m_bVisible(true)
{
	this->setNumChildrenRequiringUpdateTraversal(1);
	m_rpMT = new osg::MatrixTransform;
	this->addChild(m_rpMT.get());
}

CCelestialBody::~CCelestialBody()
{

}

void CCelestialBody::traverse( osg::NodeVisitor& nv )
{
	if (nv.getVisitorType() == osg::NodeVisitor::UPDATE_VISITOR)
	{
		m_rpMT->setMatrix(osg::Matrix::rotate(osg::DegreesToRadians(m_vecPosture.x()),osg::X_AXIS
			,osg::DegreesToRadians(m_vecPosture.y()),osg::Y_AXIS
			,osg::DegreesToRadians(m_vecPosture.z()),osg::Z_AXIS)
			*osg::Matrix::translate(m_vecPosition));
	}
	if (m_bVisible)
	{
		osg::Group::traverse(nv);
	}
}
